package com.hzw.saas.service.old.storage.listener;

import com.hzw.saas.api.old.storage.IGroupResourceService;
import com.hzw.saas.service.old.storage.event.DeleteResourceFileEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 监听资源事件
 *
 * @author zzl
 * @since 03/17/2021
 */
@Order(1)
@Component
@RequiredArgsConstructor
@Slf4j
public class OldGroupResourceListener {

    private final IGroupResourceService groupResourceService;

    @EventListener(DeleteResourceFileEvent.class)
    public void deleteResourceFile(DeleteResourceFileEvent deleteResourceFileEvent) {
        // 删除资源时删除共享数据
        groupResourceService.deleteGroupFile(null, deleteResourceFileEvent.getUserId(), deleteResourceFileEvent.getFileId());
    }

}
